import datetime
import openpyxl

wb = openpyxl.Workbook()
ws = wb.active

print(wb.sheetnames)

print(ws.title)


ws.title = 'salary luffy'

# 改写数据
ws['A1'] = 'Month'
ws['B1'] = 'Salary'
ws['A2'] = '2021-01'
ws['B2'] = 1000


#改写数据2
ws.append(["2022-02", 2000])
ws['A4'] = datetime.datetime.now().strftime("%Y-%m-%d")
ws['B4'] = 3000

# 保存workbook
wb.save("created_by_python.xlsx")


# from openpyxl.workbook import Workbook

# # 1.创建Workbook（默认会生成一个sheet）
# wb = Workbook()

# # 2.默认sheet修改名称
# sheet0 = wb.worksheets[0]
# sheet0.title = "数据集"
# c0 = sheet0.cell(1, 2)
# c0.value = "数据测试"

# sheet1 = wb.create_sheet("上海", 1)
# c1 = sheet1.cell(1, 2)
# c1.value = "哈哈哈哈哈"

# sheet2 = wb.create_sheet("北京", 2)
# c2 = sheet2.cell(2, 3)
# c2.value = "老北京扎镜面"

# # 3.保存
# wb.save('files/p3.xlsx')
